/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class ListVotoElectronicoData {
	private static final int ROW_COUNT = 100;
	
public void listTestData() throws PersistentException {
		orm.DAOFactory lDAOFactory = orm.DAOFactory.getDAOFactory();
		System.out.println("Listing Candidato...");
		orm.Candidato[] ormCandidatos = lDAOFactory.getCandidatoDAO().listCandidatoByQuery(null, null);
		int length = Math.min(ormCandidatos.length, ROW_COUNT);
		for (int i = 0; i < length; i++) {
			System.out.println(ormCandidatos[i]);
		}
		System.out.println(length + " record(s) retrieved.");
		
	}
	
	public void listByCriteria() throws PersistentException  {
		System.out.println("Listing Candidato by Criteria...");
		orm.CandidatoCriteria candidatoCriteria = new orm.CandidatoCriteria();
		// Please uncomment the follow line and fill in parameter(s) 
		//candidatoCriteria.id.eq();
		candidatoCriteria.setMaxResults(ROW_COUNT);
		orm.Candidato[] ormCandidatos = candidatoCriteria.listCandidato();
		int length =ormCandidatos== null ? 0 : Math.min(ormCandidatos.length, ROW_COUNT); 
		for (int i = 0; i < length; i++) {
			 System.out.println(ormCandidatos[i]);
		}
		System.out.println(length + " Candidato record(s) retrieved."); 
		
	}
	
	public static void main(String[] args) {
		try {
			ListVotoElectronicoData listVotoElectronicoData = new ListVotoElectronicoData();
			try {
				listVotoElectronicoData.listTestData();
				//listVotoElectronicoData.listByCriteria();
			}
			finally {
				orm.VotoElectronicoPersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
